package com.wsd.tank;

import java.io.IOException;
import java.util.Properties;

public class PorpertyMgr {
	
	private static PorpertyMgr porpertyMgr = null;
	
	private PorpertyMgr() {
	}
	
	public static PorpertyMgr build() {
		if(null == porpertyMgr) {
			porpertyMgr = new PorpertyMgr();
		}
		return porpertyMgr;
	}
	
	static Properties config =  new Properties();
	
	static {
		try {
			config.load(PorpertyMgr.class.getClassLoader().getResourceAsStream("config.properties"));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	public Integer get(String key) {
		if(null == config) return null;
		return conversion(config.getProperty(key));
	}
	public Integer conversion(String value) {
		return Integer.parseInt(value);
	}
	
	public static void main(String[] args) {
		System.out.println(PorpertyMgr.build().get("initTankCount"));
		System.out.println(PorpertyMgr.build().get("tankSpeed"));
		System.out.println(PorpertyMgr.build().get("bulletSpeed"));
		System.out.println(PorpertyMgr.build().get("gameWidth"));
		System.out.println(PorpertyMgr.build().get("gameHeight"));
	}
}
